package com.stylefeng.guns.modular.channel_promote_info.controller;

import com.stylefeng.guns.core.base.controller.BaseController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.beans.factory.annotation.Autowired;
import com.stylefeng.guns.modular.channel_promote_info.service.IChannelPromoteInfoService;

/**
 * 渠道统计控制器
 *
 * @author fengshuonan
 * @Date 2020-06-29 17:14:49
 */
@Controller
@RequestMapping("/channelPromoteInfo")
public class ChannelPromoteInfoController extends BaseController {

    private String PREFIX = "/channel_promote_info/channelPromoteInfo/";

    @Autowired
    private IChannelPromoteInfoService channelPromoteInfoService;

    /**
     * 跳转到渠道统计首页
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "channelPromoteInfo.html";
    }

    /**
     * 获取渠道统计列表
     */
    @RequestMapping(value = "/list")
    @ResponseBody
    public Object list(@RequestParam(value = "page",defaultValue = "0") Integer page,
                       @RequestParam(value = "limit",defaultValue = "20") Integer limit) {
        return channelPromoteInfoService.list(page,limit);
    }

    /**
     * 获取渠道签包设备的图表数据
     * @return
     */
    @RequestMapping(value = "/deviceBar")
    @ResponseBody
    public Object getChannelDeviceCount(@RequestParam(value = "beginTime",required = false) String beginTime,
                                        @RequestParam(value = "endTime",required = false) String endTime) {
        return channelPromoteInfoService.getChannelSignCount(beginTime,endTime);
    }

}
